package com.byq.mm.common.engine.listener.filter;

import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Stanza;

import com.byq.mm.abstractx.protocol.Interaction;

import com.byq.mm.common.engine.Environment;
import com.google.gson.Gson;

public class InteractionFilter extends AbstractFilter {

	public InteractionFilter(AbstractFilter n, Environment e) {
		super(n, e);


	}

	@Override
	protected boolean filt(Stanza data) {

		Message m = (Message) data;
		return (m.getSubject() != null && m.getSubject().equals("interaction"));
		
	}

	@Override
	protected void myprocess(Stanza data) {
		Message m = (Message) data;
		String json = m.getBody();
		Interaction i = new Gson().fromJson(json, Interaction.class);
		env.getInteractionProcessor().process(i, data.getFrom().toString());
		
		
		
	}


}
